﻿Imports Microsoft.Phone.Tasks

Public Class ExternalHyperLink
    Inherits HyperlinkButton

    Private _navigateUri As Uri

    Public Shadows Property NavigateUri() As Uri
        Get
            Return MyBase.NavigateUri
        End Get
        Set(ByVal value As Uri)
            If value.IsAbsoluteUri Then
                MyBase.NavigateUri = Nothing
                Me._navigateUri = value
                AddHandler Me.Click, AddressOf ExternalHyperlink_Click
            Else
                If Me._navigateUri IsNot Nothing Then
                    Me._navigateUri = Nothing
                    MyBase.NavigateUri = value
                    RemoveHandler Me.Click, AddressOf ExternalHyperlink_Click
                Else
                    MyBase.NavigateUri = value
                End If

            End If
        End Set
    End Property



    Public Sub ExternalHyperlink_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim wbt As New WebBrowserTask

        wbt.URL = Me.NavigateUri.AbsoluteUri
        wbt.Show()
    End Sub


End Class

